package fjut.acm.coding.controller.judge;

import fjut.acm.coding.config.interceptor.LoginRequired.LoginRequired;
import fjut.acm.coding.entity.JudgeResult;
import fjut.acm.coding.entity.result.ResultCode;
import fjut.acm.coding.entity.result.ResultJson;
import fjut.acm.coding.entity.vo.JudgeStatusVO;
import fjut.acm.coding.service.JudgeResultService;
import fjut.acm.coding.service.JudgeStatusService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


@RestController
@CrossOrigin
@RequestMapping("/judge_result")
public class JudgeResultController {
    @Resource
    JudgeStatusService judgeStatusService;

    @Resource
    JudgeResultService judgeResultService;

    @LoginRequired
    @PostMapping("/info")
    public ResultJson getJudgeResult(@RequestParam("judgeId") Integer judgeId) {
        ResultJson resultJson = new ResultJson(ResultCode.REQUIRED_SUCCESS);
        List<JudgeResult> judgeResults = judgeResultService.selectJudgeResult(judgeId);
        JudgeStatusVO judgeStatusVO = judgeStatusService.selectJudgeStatus(judgeId);
        resultJson.addInfo(judgeResults);
        resultJson.addInfo(judgeStatusVO);
        return resultJson;
    }
}
